#!/usr/bin/env python
# -*- coding: utf-8 -*-
# created at 10.04.2011

# This software is distributed under the BSD license.
# http://www.opensource.org/licenses/bsd-license.php 
# Copyright © 2011, Oleg Churkin

"""
Test data for unit tests.
"""

__version__ = "0.1"

import sys
from easylogger import log, critical, error, warning, exception, info, _smart_encode

@critical
def hello(a, b, c, qwerty=u"йцукен", abra="cadabra"):
    u"""My simple doc string.
    
    Just for the testing purposes.
        Logging check.
            Hello, World!
    """
    print "This function does nothing!", a, b, c, _smart_encode(qwerty), _smart_encode(abra)


@info
def doc_string_test1(h=None):
    """First line.
    Seconds line.
    ## Third line.
    ## Forth line.
    Fifth line."""
    print "Hello", h


@error
def doc_string_test2(a, bb, name, key="OK", value="Good"):
    """Check message formatting.
    a is {a}, bb is {bb}, name is {name},
    key is {key}, value is {value}
    """
    return a, bb, name, key, value


class MyClass(object):
    
    @error
    def get_major(self, abc="cde", hello1="1"):
        "Get major version."
        return sys.version_info[0], abc, hello1
    
    @warning
    def get_minor(self):
        return sys.version_info[1]
    
    @staticmethod            
    @exception
    def static_method(a, b, c, d, e):
        """Hello,
        static method. {a} {t}"""
        print a, b, c, d, e
    
    @classmethod
    @log
    def class_method(self, t, r=1):
        """Class Method is here."""
        print t, r
        return "new class"
    
                
if __name__ == '__main__':
    
    from easylogger import LoggingOptions
    
    # new message style
    log("Hello, World!", "test1", "test2")
    component = "brain"
    error("Error occurred in", component, "with code", 123, int)
    log.set_options(new_style_delimiter="_")
    log("brown", "fox", "jumps", "over", "lazy", "dog")
    
    # old message style
    opt = LoggingOptions()
    opt.enable_new_style = False
    log.set_options(opt)
    info("a %s %s", "b", "c")


    
            